/**
 * 
 */
package vue;

import java.awt.Color;
import java.awt.Font;
import java.awt.LayoutManager;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import controleur.ControllerClient;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * @author Zayon
 *
 */
public class Panel_RendreVelo extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6998491688748312291L;
	private ControllerClient controller;
	private JTextField textField_nom;
	private JTextField textField_prenom;
	private JTextField textField_code_utilisateur;
	private JButton btnrendre;

	/**
	 * 
	 */
	public Panel_RendreVelo(ControllerClient p_ctrl) {
		controller = p_ctrl;
		setLayout(null);
		
		JLabel lblLouerUnVlo = new JLabel("Rendre un Velo");
		lblLouerUnVlo.setFont(new Font("Calibri", Font.BOLD, 20));
		lblLouerUnVlo.setForeground(Color.BLUE);
		lblLouerUnVlo.setBounds(46, 62, 154, 16);
		add(lblLouerUnVlo);
		
		JLabel lblInsrerVotreCarte = new JLabel("Ins\u00E9rer votre carte d'abonn\u00E9");
		lblInsrerVotreCarte.setBounds(30, 104, 196, 16);
		add(lblInsrerVotreCarte);
		
		textField_nom = new JTextField();
		textField_nom.setEditable(false);
		textField_nom.setBounds(95, 139, 154, 22);
		add(textField_nom);
		textField_nom.setColumns(10);
		
		JLabel lblNom = new JLabel("nom :");
		lblNom.setBounds(46, 145, 40, 16);
		add(lblNom);
		
		JLabel lblPrenom = new JLabel("prenom :");
		lblPrenom.setBounds(30, 180, 56, 16);
		add(lblPrenom);
		
		textField_prenom = new JTextField();
		textField_prenom.setEditable(false);
		textField_prenom.setColumns(10);
		textField_prenom.setBounds(95, 174, 154, 22);
		add(textField_prenom);
		
		textField_code_utilisateur = new JTextField();
		textField_code_utilisateur.setEditable(false);
		textField_code_utilisateur.setColumns(10);
		textField_code_utilisateur.setBounds(95, 209, 154, 22);
		add(textField_code_utilisateur);
		
		btnrendre = new JButton("Rendre le velo");
		btnrendre.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				controller.rendreVelo();
			}
		});
		btnrendre.setBounds(79, 241, 147, 25);
		add(btnrendre);
	}

	public void setTextFields(String prenom, String nom, int code_u) {
		textField_nom.setText(nom);
		textField_prenom.setText(prenom);
		textField_code_utilisateur.setText(""+code_u);
	}
	
	public void disableButton() {
		btnrendre.setEnabled(false);
	}
	public void enableButton() {
		btnrendre.setEnabled(true);
	}
	
	/**
	 * @param layout
	 */
	public Panel_RendreVelo(LayoutManager layout) {
		super(layout);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param isDoubleBuffered
	 */
	public Panel_RendreVelo(boolean isDoubleBuffered) {
		super(isDoubleBuffered);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param layout
	 * @param isDoubleBuffered
	 */
	public Panel_RendreVelo(LayoutManager layout, boolean isDoubleBuffered) {
		super(layout, isDoubleBuffered);
		// TODO Auto-generated constructor stub
	}
}
